local que_jidong = fk.CreateSkill {
    name = "que_jidong",
    anim_type = "control",
    tags = { Skill.Compulsory }
}
Fk:loadTranslationTable {
    ["que_jidong"] = "悸动",
    [":que_jidong"] = "锁定技，每名角色限一次，当其本局游戏受到<a href='doubledamage'>第二次伤害</a>时，你摸X张牌，若该角色不为你，其本局游戏无法响应你使用的牌(X为其累计受到的伤害)。",

    ["doubledamage"] = "若首次受到伤害，或第二次受到伤害后，导致该角色进入濒死状态，则立刻发动〖悸动〗效果",
}
que_jidong:addEffect(fk.Damaged, {
    can_trigger = function(self, event, target, player, data)
        local mark = player:getTableMark("que_jidong_wfxy")
        return player:hasSkill(que_jidong.name) and target:getMark("que_jidong") > 0 and
            target:getMark("que_jidong_damaged") > 1 and not table.contains(mark, target.id)
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        player:drawCards(target:getMark("que_jidong"), que_jidong.name)
        room:addTableMarkIfNeed(player, "que_jidong_wfxy", target.id)
    end,
})

que_jidong:addEffect(fk.DamageInflicted, {
    can_refresh = function(self, event, target, player, data)
        return player:hasSkill(que_jidong.name) and target:getMark("que_jidong_damaged") < 2
    end,
    on_refresh = function(self, event, target, player, data)
        local room = player.room
        room:addPlayerMark(target, "que_jidong", data.damage)
        room:addPlayerMark(target, "que_jidong_damaged", 1)
    end,
})

que_jidong:addEffect(fk.CardUsing, {
    can_trigger = function(self, event, target, player, data)
        local mark = player:getTableMark("que_jidong_wfxy")
        return target == player and player:hasSkill(que_jidong.name) and #mark > 0 and data.card
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local mark = player:getTableMark("que_jidong_wfxy")
        data.disresponsiveList = data.disresponsiveList or {}
        for _, i in ipairs(room:getOtherPlayers(player)) do
            if table.contains(mark, i.id) then
                table.insertIfNeed(data.disresponsiveList, i)
            end
        end
    end,
})

que_jidong:addEffect(fk.EnterDying, {
    can_trigger = function(self, event, target, player, data)
        local mark = player:getTableMark("que_jidong_wfxy")
        return player:hasSkill(que_jidong.name) and target:getMark("que_jidong") > 0 and
            not table.contains(mark, target.id)
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        player:drawCards(target:getMark("que_jidong"), que_jidong.name)
        room:addTableMarkIfNeed(player, "que_jidong_wfxy", target.id)
    end,
})
return que_jidong
